/********************************************************
Para poder sacar la imagen del streaming se necesita
width, height
direccion ip
puerto
accion: stream o snapshot
*********************************************************/

#include <libplayercore/playercore.h>
#include <curl/curl.h>


#define DEFAULT_IPADDR "localhost"
#define DEFAULT_PORT 8080
#define DEFAULT_ACTION "snapshot"
#define DEFAULT_FILE_URL "./img.jpg"

typedef struct{
	const char *ipAddr;
	unsigned int port;
	const char *action;
	char *http_dir;
	
}connection_cam_data_t;


class StreamCamera : public Driver
{
	// Main function for device thread.
	private: 
		virtual void Main();

  	// Update the device data (the data going back to the client).
  	void RefreshData();

  	//connection data
  	connection_cam_data_t conn;
  	
  	// Image dimensions
  	int width, height;
  	
  	//file where the image will be saved
  	FILE *fp;
		//where the file will be saved
		const char* fileUrl;
		
		//cURL variables
		CURLcode curlResult;
		CURL * curlConn;
		//if debug=1, you will see debugging information from cURL
		int curlDebug;
		
		// Data to send to server
		player_camera_data_t data;


  // Constructor
  public: 
  	StreamCamera( ConfigFile* cf, int section);

  	// Setup/shutdown routines.
  	virtual int Setup();
  	virtual int Shutdown();

	  // This method will be invoked on each incoming message
  	virtual int ProcessMessage(MessageQueue* resp_queue,
                                     player_msghdr * hdr,
                                     void * data);
  
};

